package com.example.spring_database.mappers;

import com.example.spring_database.entity.book;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface bookMapper {
    @Select("select * from books")
    List<book> selectAll();

    @Select("select * from books where id = #{id}")
    book select_one_book(int id);

    @Insert("insert into books(book_name,auther,press,month,year,store,filename) values(#{book_name}, #{auther}, #{press}, #{month}, #{year}, #{store},#{filename})")
    @Options(useGeneratedKeys = true,keyProperty = "id")
    void add(book book);

    @Delete("delete from books where id = #{id}")
    void deleteById(int id);

    @Update("update books set book_name = #{book_name} ,auther = #{auther} , press = #{press},month = #{month},year = #{year},store = #{store}, filename = #{filename} where id = #{id}")
    void update(book book);

}
